<%@taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript">
$(function() {
	$('img.serverImage').live("click",function(){
//	        var trtag = $(this).parents('tr').children().find('.friendlyName').html();
           // alert('Click called now');
    	    var serverDivId = $(this).parents('tr').attr("id");             
    	    /* TODO - Find a better way to do this */
	        var friendlyNameToDelete = $("#" + serverDivId).find("td").eq(1).html().trim();  
	        //alert("Friendly name is " + trtag);
	        deleteServer(friendlyNameToDelete,serverDivId);
    	    return false;
    		});
});

function deleteServer(friendlyNameToDelete,serverDivId) {
    //alert("Calling delete now " + friendlyNameToDelete);	
    $('#message').html('<img src=\"images/loading.gif\"/> Deleting settings for server ' + friendlyNameToDelete);
    $.post("/eftweb/delete_settings.html", {friendlyName:friendlyNameToDelete}, function(data) {
    	//alert("Data received " + data);
        $('#message').empty();
        $('#message').html('Succesfull made those changes');
	    fadeAndRemove(serverDivId); 
    });
}


function fadeAndRemove(serverDivId) {
		$("#" + serverDivId).animate({
			opacity : 0.0
		}, 600, function() {
			$("#" + serverDivId).remove();
		});
	}
</script>
</head>
<body bgcolor="#E6E6FA">
	<fieldset>
		<legend>EPPD View Servers</legend>
		<table id="eppdServers" width="800" border="1">
			<s:iterator value="eppdServerList" status="stat">
				<tr id="row<s:property value="#stat.index"/>" >
					<td><img src="images/server.png" height="20" width="20"></img>
					</td>
					<td class="friendlyName"><s:property value="FriendlyName"/>
					</td>
					<td><s:property value="EppdIp" />
					</td>
					<td><s:property value="EppdPort" />
					</td>
					<td><s:property value="PcksFileName" />
					</td>
					<td><s:property value="JksFileName" />
					</td>
					<td>Extensions supported :<s:property value="extensions" />
					</td>
					<td><img src="images/not_connected.png" class="serverImage" height="20" width="20" />
					</td>
				</tr>
			</s:iterator>
		</table>
	</fieldset>
	<div id="message"></div>
	<br>
	<br>
</body>
</html>
